<template>
	<view class="navbar"
		:style="{height:appInfoStore.getInfo().navBarHeight+appInfoStore.getInfo().statusbar+'px','padding-top':appInfoStore.getInfo().statusbar+'upx'}">
		<view class="left">
			<view v-if="showLeft" @click="leftCallback">
				返回
			</view>

		</view>
		<view class="content">
			<view v-if="title">
				{{title}}
			</view>
			<slot></slot>
		</view>
		<view class="right">
			<slot name="right"></slot>
		</view>
	</view>
	<view :style="{height:appInfoStore.getInfo().navBarHeight+appInfoStore.getInfo().statusbar+'px'}">

	</view>
</template>

<script setup>
	import {
		useAppInfoStore
	} from '@/stores/appinfo.js'
	import {
		ref,
	} from 'vue'
	const appInfoStore = useAppInfoStore()
	const props = defineProps({
		showRight: {
			type: Boolean,
			default: true
		},
		title: {
			type: String,
			default: ''
		},
		showLeft: {
			type: Boolean,
			default: true
		},
		leftCallback: {
			type: Function,
			default: () => {}
		}
	})
	console.log(props.title);
	const leftCallback = () => {
		if (props.leftCallback) {
			props.leftCallback()
		} else {
			uni.navigateBack()
		}
	}
</script>

<style>
	.navbar {
		background: linear-gradient(to right, #9060df, #6356de);
		width: 100%;
		position: fixed;
		display: flex;
		color: #fff;
		align-items: center;
		justify-content: center;
		padding: 0 10upx;

		.left {
			width: 20upx;
		}

		.content {
			text-align: center;
			flex: 1;
		}

		.right {
			width: 20upx;
		}
	}
</style>